package org.mihalovic.PES.Core.Graph;

import org.mihalovic.PES.Core.Graph.Rank.PageRankScore;



/**
 * Graph's vertex
 */
public class Node
{
    private int id;
    private String name;
    private PageRankScore rank;
    private boolean hasInEdges;


    public Node(int id, String name, PageRankScore rank) {
        this.id=id;
        this.name = name;
        this.rank = rank;
        hasInEdges = false;
    }


    /**
     *
     * @param name it's expected that <code>name</code> is unique node's ID
     * among containing graph.
     */
    public Node( String name){
        this(0, name, null);
    }

    public int getID(){ return id; }


    /**
     * @return User's nickname
     */
    public String getName(){ return name; }


    /**
     * @return Result PageRank score after ranking was run.
     */
    public PageRankScore getRank() {
        return rank;
    }

    public void setRank(PageRankScore rank){
        this.rank=rank;
    }

    
    /** Determines if Porada member corresponding to this Node has received any agreement */
    public boolean HasInEdges() { return hasInEdges; }
    public void setHasInEdges(boolean value) { hasInEdges = value; }


    @Override
    public int hashCode(){ return name.hashCode(); }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) return false;

        if (getClass() != obj.getClass()) return false;

        final Node other = (Node) obj;
        return (this.id==other.id && this.name.equals(other.name) );
    }

    @Override
    public String toString() {
        return name;
    }
}
